package demo.practice.binary_search;

public class Offer_2 {
    public int minArray(int[] numbers) {
        int min = 0;
        int max = numbers.length - 1;
        while (min < max) {
            int mid = min + (max - min) / 2;
            if (numbers[mid] < numbers[max]) {
                max = mid;
            } else if (numbers[mid] > numbers[max]) {
                min = mid + 1;
            } else {
                max -= 1;
            }
        }
        return numbers[min];
    }
}
